import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_1/utils/db/DatabaseHelper.dart';
import 'package:flutter_1/utils/language/message.dart';
import 'package:flutter_1/utils/style.dart';
import 'package:flutter_1/views/login.dart';
import 'package:get/get_navigation/src/root/get_material_app.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  if (Platform.isWindows) {
    // 初始化 sqflite_common_ffi
    databaseFactory = databaseFactoryFfi;
  }

  /// 初始化数据库
  DatabaseHelper.getDatabase();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: '货运管理系统',
      debugShowCheckedModeBanner: false, // 消除右上角图标
      translations: Message(),
      locale: Locale('zh', 'CN'), //设置默认语言
      fallbackLocale: Locale("zh", "CN"), // 在配置错误的情况下,使用的语言
      theme: ThemeData(
          appBarTheme: const AppBarTheme(surfaceTintColor: Colors.transparent),
          colorScheme: ColorScheme.fromSeed(seedColor: Style.c_8cd5ff),
          useMaterial3: true,
          highlightColor: const Color.fromRGBO(0, 0, 0, 0),
          splashColor: const Color.fromRGBO(0, 0, 0, 0)),
      home: const Login(),
    );
  }
}
